home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7413 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  39 lines

  1. Path: amaryllisp1.appsig.com!user
  2. From: larry_kearney@appsig.com (Larry Kearney)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: hex to dec function?
  5. Date: Fri, 23 Feb 1996 08:06:46 -0700
  6. Organization: Who ever said I was organized?
  7. Message-ID: <larry_kearney-2302960806460001@amaryllisp1.appsig.com>
  8. References: <4gdh1b$bg@mailhost.mwmicro.com>
  9. NNTP-Posting-Host: amaryllisp1.appsig.com
  10.  
  11. In article <4gdh1b$bg@mailhost.mwmicro.com>, aschlies@citynet.net wrote:
  12.  
  13. > Hi There,
  14. > Is there a function that converts HEX to Dec in ANSI C?
  15. > Why re-invent the wheel?
  16. > Thanks
  17. > Tony
  18.  
  19. I assume you mean convert a character string containing hex digits
  20. ('A'-'F','0'-'9') into a decimal integer. If so, use
  21.  
  22.    unsigned int int_value;
  23.    unsigned long int long_int_value;
  24.    char *string_buffer;
  25.  
  26.    ...
  27.  
  28.    sscanf( string_buffer, "%x", int_value );
  29.  
  30.    sscanf( string_buffer, "%lx", long_int_value );
  31.  
  32. -- 
  33. Larry Kearney                   |   "You want fries with that?"
  34. Applied Signal Technology       |
  35. larry_kearney@appsig.com        |
  36.